/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 *
 * @author Kvest
 */
public class Order4 extends Order3 {
    public String sourceWhence;
    public double orderCostForDriver;
    public boolean canFirstForAnyParking;
    public double distanceToPointOfDelivery;
    public boolean concessional;
            
    public Order4(int _orderID)
    {
        super(_orderID);
        
        sourceWhence = "";
        orderCostForDriver = 0;
        canFirstForAnyParking = false;
        distanceToPointOfDelivery = 0;
        concessional = false;
    }
    
    public Order4(byte[] data) throws IOException
    { 
        this(-1);
       
        ByteArrayInputStream bais = new ByteArrayInputStream(data);
        DataInputStream dis = new DataInputStream(bais);

        try
        {  
            readFields(dis);
        }
        finally
        {
            try
            {
                dis.close();
                bais.close();
            }catch(Exception ex){}
        }       
    }
    
    protected void readFields(DataInputStream dis) throws IOException {
//        sourceWhence = dis.readUTF();
//        orderCostForDriver = dis.readDouble();
//        canFirstForAnyParking = dis.readBoolean();
//        distanceToPointOfDelivery = dis.readDouble();
//        concessional = dis.readBoolean();
        
        super.readFields(dis);        
    }
    
    protected void writeFields(DataOutputStream dos) throws IOException {
        //Пока не сохраняем эти поля - они нам не нужны
//        dos.writeUTF(sourceWhence);
//        dos.writeDouble(orderCostForDriver);
//        dos.writeBoolean(canFirstForAnyParking);
//        dos.writeDouble(distanceToPointOfDelivery);
//        dos.writeBoolean(concessional);

        super.writeFields(dos);
    }
    
    public void copy(Order src) {
        super.copy(src);
        
        if (src instanceof Order4)
        {
            sourceWhence = ((Order4)src).sourceWhence;
            orderCostForDriver = ((Order4)src).orderCostForDriver;
            canFirstForAnyParking = ((Order4)src).canFirstForAnyParking;
            distanceToPointOfDelivery = ((Order4)src).distanceToPointOfDelivery;
            concessional = ((Order4)src).concessional;
        }       
    } 
}
